package teleradiologia.service;

import java.util.List;

import teleradiologia.domain.Diagnosticlab;
import teleradiologia.domain.Doctor;
import teleradiologia.domain.Person;
import teleradiologia.repository.DiagnosticlabDao;
import teleradiologia.repository.DoctorDao;
import teleradiologia.repository.PersonDao;

public class DoctorManipulatorImpl implements DoctorManipulator {
	private DoctorDao doctorDao;
	private PersonDao personDao;
	@SuppressWarnings("unused")
	private DiagnosticlabDao diagnosticlabDao;


	@Override
	public void delete(Doctor doctor) {
		this.doctorDao.delete(doctor);
		this.personDao.delete(doctor.getPerson());	
	}

	@Override
	public Doctor getByNip(String nip) {
		return this.doctorDao.getByNip(nip);
	}


	@Override
	public Doctor geByIdPerson(long idPerson) {
		return this.doctorDao.getByIdPerson(idPerson);
	}
	
	@Override
	public void update(Doctor doctor) {
		this.personDao.update(doctor.getPerson());
		this.doctorDao.update(doctor);
	}

	@Override
	public String create(Doctor doctor, Person person, Diagnosticlab diagnosticlab) {
		long id= this.personDao.create(person);
		doctor.setPerson(this.personDao.getById(id));
		doctor.setDiagnosticlab(diagnosticlab);
		
		return this.doctorDao.create(doctor);
	}

	@Override
	public List<Doctor> getAll() {
		return this.doctorDao.getAll();
	}
	
	public void setPersonDao(PersonDao personDao) {
		this.personDao = personDao;
	}

	public void setDiagnosticlabDao(DiagnosticlabDao diagnosticlabDao) {
		this.diagnosticlabDao = diagnosticlabDao;
	}
	
	@Override
	public void setDoctorDao(DoctorDao doctorDao) {
		this.doctorDao = doctorDao;
	}

	@Override
	public List<Doctor> getAllByKrsnumber(String krsnumber) {
		return this.doctorDao.getAllByKrsnumber(krsnumber);
	}
}
